package com.ingesup.caribou.client.gui.app;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class FrameConnection extends JDialog {
	private static final long serialVersionUID = -6665609063607371441L;
	private final JPanel contentPanel = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			FrameConnection dialog = new FrameConnection(null);
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public FrameConnection(JFrame parent) {
		super(parent);
		setTitle("Connexion");
		setBounds(100, 100, 422, 158);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JPanel labelPane = new JPanel(new GridLayout(2,1));
		JLabel ipLabel = new JLabel("IP : ");
		JLabel portLabel = new JLabel("Port : ");
		labelPane.add(ipLabel);
		labelPane.add(portLabel);
		
		JPanel textFieldPane = new JPanel(new GridLayout(2,1));
		JTextField ipField = new JTextField("localhost");
		textFieldPane.add(ipField);
		JTextField portField = new JTextField("4567");
		textFieldPane.add(portField);
		
		getContentPane().add(labelPane, BorderLayout.WEST);
		getContentPane().add(textFieldPane, BorderLayout.CENTER);
		
		JPanel buttonPane = new JPanel();
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);

		JButton okButton = new JButton("OK");
		okButton.setActionCommand("OK");
		buttonPane.add(okButton);
		getRootPane().setDefaultButton(okButton);

		JButton cancelButton = new JButton("Cancel");
		cancelButton.setActionCommand("Cancel");
		buttonPane.add(cancelButton);
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();				
			}
		});		
	}

}
